
package eteam.aps.config;

import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 *
 * @author gyiyikai
 */
//@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

	private static final boolean GATEWAY_EXIST = true;

	// Configure cross origin requests processing.
	// When allowCredentials is true, allowedOrigins cannot contain the special
	// value "*"
	// since that cannot be set on the "Access-Control-Allow-Origin" response
	// header.
	// To allow credentials to a set of origins, list them explicitly
	// or consider using "allowedOriginPatterns" instead.
	@Override
	public void addCorsMappings(CorsRegistry registry) {
		if (!GATEWAY_EXIST) {
			registry.addMapping("/**").allowedMethods("*")//
					.allowCredentials(true).allowedOrigins("*")//
					.maxAge(3600);
		}
	}

}
